<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Retrieval Result</title>
<style type="text/css">
.wrap{ 
margin-top:10px;
}
.wrap li{ 
width:230px; height:128px;  margin-left:8px; margin-top:10px; margin-bottom:10px; float:left; text-align:center; display:inline;
}
.wrap li h1{ 
font-size:12px; color:#005eac; line-height:22px; text-align:center; margin-top:5px; font-weight:normal;
}
.wrap li p{ 
color:#666; line-height:22px; text-align:center;
}
</style>
</head>
<body>
<!-- 
http://wenku.baidu.com/view/efce661252d380eb62946da1.html 
application.getRealPath("/") + "/testwav/China1[Part 1]test.wav"
-->

<div>
<%@ page import="audio.Searcher" %>
<%@ page import="java.util.Arrays" %>
<%@ page import="java.util.List" %>
<%@ page import="java.util.ArrayList" %>
<%@ page import="jspClass.VideoSearcher" %>
<%@ page import="jspClass.Util" %>


<%
String key = (String)session.getAttribute("uploadedfile");
session.setAttribute("uploadedfile", null);
String pos = request.getParameter("listpos") == null ? "-1":request.getParameter("listpos");
int listPostion = Integer.parseInt(pos);
if(key == null || key == ""){
	List<String> videoList = new ArrayList<String>();
	switch(listPostion){
	default:
		videoList.add("中国1[Part 1]");
		videoList.add("海贼王1[Part 2]");
		videoList.add("嘻哈1");
		videoList.add("火影1[Part 1]");
		videoList.add("中国2[Part 2]");
		videoList.add("海贼王2[Part 2]");
		videoList.add("嘻哈2");
		videoList.add("火影2[Part 1]");
		break;
	case 0:
		videoList.add("中国1[Part 1]");
		videoList.add("中国1[Part 2]");
		videoList.add("中国1[Part 3]");
		videoList.add("中国1[Part 4]");
		videoList.add("中国2[Part 1]");
		videoList.add("中国2[Part 2]");
		videoList.add("中国2[Part 3]");
		videoList.add("中国2[Part 4]");
		break;
	case 1:
		videoList.add("嘻哈1");
		videoList.add("嘻哈2");
		videoList.add("嘻哈3");
		videoList.add("嘻哈4");
		videoList.add("嘻哈5");
		videoList.add("嘻哈6");
		videoList.add("嘻哈7");
		videoList.add("嘻哈8");
		break;
	case 2:
		videoList.add("海贼王1[Part 1]");
		videoList.add("海贼王1[Part 2]");
		videoList.add("海贼王1[Part 3]");
		videoList.add("海贼王1[Part 4]");
		videoList.add("海贼王2[Part 1]");
		videoList.add("海贼王2[Part 2]");
		videoList.add("海贼王2[Part 3]");
		videoList.add("海贼王2[Part 4]");
		break;
	case 3:
		videoList.add("火影1[Part 1]");
		videoList.add("火影1[Part 2]");
		videoList.add("火影1[Part 3]");
		videoList.add("火影1[Part 4]");
		videoList.add("火影2[Part 1]");
		videoList.add("火影2[Part 2]");
		videoList.add("火影2[Part 3]");
		videoList.add("火影2[Part 4]");
		break;
	}
	
	out.println(Util.writeDefaultResultList(videoList));
}else{
	boolean isVideoRetrieval = Boolean.parseBoolean((String)session.getAttribute("videoretrieval"));
	boolean isAudioRetrieval = Boolean.parseBoolean((String)session.getAttribute("audioretrieval"));
	session.setAttribute("videoretrieval", "");
	session.setAttribute("audioretrieval","");
	if(!isVideoRetrieval && isAudioRetrieval){
		String[][] result = Searcher.execute(key);	
		if(result != null){
			out.println(Util.writeAudioRetrivalResultList(result));
		}
	}else if(isVideoRetrieval && !isAudioRetrieval){
		List<String> videoList = VideoSearcher.execute(key, 8);
		if(videoList != null && videoList.size() != 0){
			
			out.println("<h5>按匹配度由高到低显示：</h5>");
			out.println("<hr>");
			out.println(Util.writeVideoRetrievalResultList(videoList));
		}
	}
	
}
	
%>
</div>
</body>
</html>